from selenium.webdriver.common.by import By
import time

class RegisterOperation:

    def register(self,driver,username,pwd,repwd):

        driver.find_element(By.XPATH, '//div[@class="login-center1"]/div[2]/a').click()
        # 注册页面链接
        time.sleep(1)
        driver.find_element(By.XPATH, '//input[@id="username"]').send_keys(username)
        driver.find_element(By.XPATH, '//input[@id="password"]').send_keys(pwd)
        driver.find_element(By.XPATH, '//input[@id="repassword"]').send_keys(repwd)
        driver.find_element(By.XPATH, '//button[@id="login_btn"]').click()
        time.sleep(1)

    def getSuccessResult(self,driver):
        return driver.current_url

    # 重复密码为空的结果
    def getRePwdResult(self,driver):

        return driver.find_element(By.XPATH,"//div[@class='login-center1']/form/div[3]/span[1]").text

    # 注册密码为空的结果
    def getPwdResult(self,driver):
        return driver.find_element(By.XPATH, "//div[@class='login-center1']/form/div[2]/span[1]").text

    # 两次密码不相同
    def getPwdAndRePwdResult(self,driver):

        return driver.find_element(By.XPATH,"/html/body/div/div/div/form/div[3]/span[1]").text

    # 密码 和 确认密码均为空的情况
    def getLackPwdAndRePwdErrorResult(self,driver):

        return driver.find_element(By.XPATH,"/html/body/div/div/div/form/div[2]/span[1]").text

